package com.lhkj.ct.meta.modules.gauge.service.impl;

import com.lhkj.ct.base.mybatis.extension.service.impl.BatchHandleServiceImpl;
import com.lhkj.ct.meta.modules.gauge.mapper.GaugeOptionMapper;
import com.lhkj.ct.meta.modules.gauge.model.entity.TblGaugeOption;
import com.lhkj.ct.meta.modules.gauge.service.GaugeOptionService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2023-10-08
 */
@Service
public class GaugeOptionServiceImpl extends BatchHandleServiceImpl<GaugeOptionMapper, TblGaugeOption> implements GaugeOptionService {

//    @Resource
//    private QutLogicService logicService;

//    @Override
//    public boolean saveBatch(Collection<TblGaugeOption> entityList) {
//        boolean save = super.saveBatch(entityList, 500);
//        return save;
////        if (!save) return false;
////        List<TblQutLogic> logics = entityList.stream()
////                .filter(o -> CollectionUtils.isNotEmpty(o.getLogic()))
////                .flatMap(o -> o.getLogic().stream().peek(l -> {
////                    l.setLocOptId(o.getOptId());
////                    l.setLocQutId(o.getQuestionId());
////                }))
////                .collect(Collectors.toList());
////        return logicService.saveBatch(logics);
//    }

//    @Override
//    public void compareAndUpdate(TblGaugeOption source, TblGaugeOption target) {
//        if (!source.equals(target)) {
//            updateById(source);
//        }
////        // 收集旧的id
////        List<String> optIds = target.getLogic().stream().map(TblQutLogic::getLocId).collect(Collectors.toList());
////        // 按照id进行合并
////        Map<String, TblQutLogic> optionMap = target.getLogic().stream().collect(
////                Collectors.toMap
////                        (TblQutLogic::getLocId, each -> each, (value1, value2) -> value1)
////        );
////        // 新增的选项
////        List<TblQutLogic> newOptions = new ArrayList<>();
////        for (TblQutLogic logic : source.getLogic()) {
////            logic.setLocQutId(source.getQuestionId());
////            logic.setLocOptId(source.getOptId());
////            // 新增
////            if (StringUtils.isBlank(logic.getLocId())) {
////                newOptions.add(logic);
////            }
////            optIds.remove(logic.getLocId());
////            // 无变化
////            if (target.getLogic().remove(logic)) {
////                continue;
////            }
////            // 有更新
////            if (optionMap.containsKey(logic.getLocId())){
//////                logicService.compareAndUpdate(logic, optionMap.get(logic.getLocId()));
////            }
////        }
////        logicService.saveBatch(newOptions);
////        if (CollectionUtils.isEmpty(optIds)) {
////            logicService.removeByIds(optIds);
////        }
//    }
}
